package com.syt.tank.handler;

import org.apache.mina.core.session.IoSession;
import org.springframework.web.bind.annotation.RequestMapping;

import com.syt.mina.handler.SytHandler;
import com.syt.tank.message.ChatToEveryoneMsg;

import flex.messaging.io.amf.ASObject;


@RequestMapping("/chat")
public class ChatHandler extends SytHandler{
	
	@RequestMapping(value="/someone")
	public void chatToSomeone(IoSession session, Object message) {
		System.out.println("someone");
	}
	
	@RequestMapping(value="/everyone")
	public void chatToEveryone(IoSession session, Object message) {
		ChatToEveryoneMsg msg = new ChatToEveryoneMsg(String.valueOf(session.getId()), null);
		ASObject messageAs = (ASObject) message;
		msg.setContent((String)messageAs.get("content"));
		getSessionManager().sendMessageTo(session, msg);
	}
	
}
